package com.lpfy.dtxc.viewutils;


import android.content.Context;
import android.net.Uri;
import android.util.AttributeSet;
import android.widget.VideoView;

import com.lpfy.dtxc.utils.SSLUtils;

import javax.net.ssl.HttpsURLConnection;


public class CustomVideoView extends VideoView {

    public CustomVideoView(Context context){
        super(context);
    }

    public CustomVideoView(Context context,AttributeSet attributeSet){
        super(context,attributeSet);
    }

    public CustomVideoView(Context context,AttributeSet attributeSet,int defStyle){
        super(context,attributeSet,defStyle);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec){
        int width = getDefaultSize(0,widthMeasureSpec);
        int height = getDefaultSize(0,heightMeasureSpec);

        setMeasuredDimension(width,height);
    }

    @Override
    public void setVideoURI(Uri uri) {
        super.setVideoURI(uri);
        try {
            HttpsURLConnection.setDefaultSSLSocketFactory(SSLUtils.createSSLSocketFactory());
            HttpsURLConnection.setDefaultHostnameVerifier(new SSLUtils.TrustAllHostnameVerifier());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
